package com.wonders.framework.auto.builder.code.convert.instance;

import com.wonders.framework.auto.builder.code.convert.BaseTagConvert;
import com.wonders.framework.auto.builder.code.entity.vo.BuildColumn;
import com.wonders.framework.auto.builder.code.entity.vo.BuildTable;

/**
 * 列表页面grid标签转换器
 * 
 * @author WuBin
 * 
 */
public class ListGridConvert extends BaseTagConvert {

	@Override
	public String convert(String str, String tag, BuildTable buildTable) {
		String prefix = super.getPrefix(str, tag);
		str = "";
		for (int i = 0; i < buildTable.getColumns().size(); i++) {
			BuildColumn buildColumn = buildTable.getColumns().get(i);
			str += prefix + "<div field=\"" + buildColumn.getPropertyName()
					+ "\" headerAlign=\"center\"";
			if ("Date".equals(buildColumn.getTypeName())) {
				str += " dateFormat=\"yyyy-MM-dd HH:mm:ss\"";
			}
			str += ">" + buildColumn.getPropertyMean() + "</div>";
			if (i + 1 != buildTable.getColumns().size()) {
				str += "\n";
			}
		}
		return str;
	}

}
